import { ref, Ref } from 'vue';
import tableDefineFunction from '@/hooks/table-hooks';
import { {{ pascal_case }}Query, {{ pascal_case }}VO } from './{{kebab_case}}';
import { page } from './{{kebab_case}}.api';

const defColumns = [
  {
    show: true,
    title: '序号',
    dataIndex: 'serialNumber',
    slotName: 'serialNumber',
    align: 'center',
    width: 65,
    fixed: 'left',
  },
{% for column in columns %}
   {
    show: {%if column.前端默认展示 == '是'%} true {%else%} false {%endif%}, 
    title: '{{ column.注解 }}',
    dataIndex: '{{ to_camel_case(column.列名) }}',
    slotName: '{{ to_camel_case(column.列名) }}',
    {%if column.前端是否排序 == '是'%}
    sortable: {
      sorter: true,
      sortDirections: ['ascend', 'descend'],
    },
    {%endif%}
    minWidth: 120,
   },
{% endfor %}
];
const tableData: Ref<{{ pascal_case }}VO[]> = ref([]);
const params: Ref<{{ pascal_case }}Query> = ref({});
export default function defineFunction() {
  const {
    pagination,
    selectedKeys,
    rowSelection,
    serialNumberFormatter,
    onPageChange,
    sorterChange,
    onPageSizeChange,
    onSearch,
    getTableData,
  } = tableDefineFunction(tableData, params, page);
  return {
    selectedKeys,
    rowSelection,
    pagination,
    tableData,
    onPageChange,
    sorterChange,
    getTableData,
    onPageSizeChange,
    serialNumberFormatter,
    params,
    onSearch,
    defColumns,
  };
}
